﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Watch_It
{
    class Element
    {
        public float AspectRatio
        {
            get { return _aspectRatio; }
            set { _aspectRatio = value; }
        }
        private float _aspectRatio;

        public Model Dessin
        {
            get {return _dessin;}
            set { _dessin = value; }
        }
        private Model _dessin;

        public Vector3 Position
        {
            get { return _position; }
            set { _position = value; }
        }
        private Vector3 _position;

        public float Rotation
        {
            get { return _rotation; }
            set { _rotation = value; }
        }
        private float _rotation;

        public void Dessine(Camera maCamera)
        {
            Matrix[] matPerso = new Matrix[Dessin.Bones.Count];
            Dessin.CopyAbsoluteBoneTransformsTo(matPerso);
            foreach (ModelMesh mesh in Dessin.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //effect.LightingEnabled = true;
                    //effect.TextureEnabled = true;
                    //effect.VertexColorEnabled = true;
                    //effect.AmbientLightColor = new Vector3(1f, 0f, 1f);
                    effect.EnableDefaultLighting();
                    effect.World = Matrix.Identity;
                    effect.World = matPerso[mesh.ParentBone.Index] * Matrix.CreateRotationY(MathHelper.ToRadians(Rotation)) * Matrix.CreateTranslation(Position);
                    effect.View = maCamera.Vue;
                    effect.Projection = maCamera.Perspective;
                }
                mesh.Draw();
            }
        }
    }
}
